//
//  HXTodayPlayerWP.m
//  ZCooking
//
//  Created by 韩旭 on 16/8/30.
//  Copyright © 2016年 HX_. All rights reserved.
//

#import "HXTodayPlayerWP.h"
#import "HX_Macro.h"

@interface HXTodayPlayerWP ()
@property (nonatomic, strong) UIWebView *hxWebPage;
@end

@implementation HXTodayPlayerWP
- (void)viewDidAppear:(BOOL)animated {
    [super viewDidAppear:animated];
    [self creatRightBtn];
    self.navigationController.navigationBarHidden = NO;
}
- (void)creatRightBtn {
    UIButton *right = [UIButton buttonWithType:UIButtonTypeCustom];
    right.frame = CGRectMake(0, 0, 30, 30);
    [right setImage:[UIImage imageNamed:@"分享"] forState:UIControlStateNormal];
    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:right];
    [right addTarget:self action:@selector(addRightBtn:) forControlEvents:UIControlEventTouchUpInside];
}
- (void)addRightBtn:(UIButton *)btn {
    [btn setImage:[UIImage imageNamed:@"分享_p"] forState:UIControlStateNormal];
    [btn removeTarget:self action:@selector(removeBtn:) forControlEvents:UIControlEventTouchUpInside];
    [btn addTarget:self action:@selector(removeBtn:) forControlEvents:UIControlEventTouchUpInside];
}
- (void)removeBtn:(UIButton *)btn {
    [btn setImage:[UIImage imageNamed:@"分享"] forState:UIControlStateNormal];
    [btn removeTarget:self action:@selector(removeBtn:) forControlEvents:UIControlEventTouchUpInside];
    [btn addTarget:self action:@selector(addRightBtn:) forControlEvents:UIControlEventTouchUpInside];
}
- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor redColor];
    [self creatWebViewPage];
}
- (void)creatWebViewPage {
    self.hxWebPage = [[UIWebView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT)];
    NSURL *url = [NSURL URLWithString:self.todayUrl];
    NSURLRequest *request = [NSURLRequest requestWithURL:url];
    [self.hxWebPage loadRequest:request];
    [self.view addSubview:_hxWebPage];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
